<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改领用记录')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-receiveRecord-edit" th:object="${receiveRecord}">
        <input name="receiveId" th:field="*{receiveId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">OA编号：</label>
            <div class="col-sm-8">
                <input name="receiveOaNumber" th:field="*{receiveOaNumber}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">领取工号：</label>
            <div class="col-sm-8">
                <input name="receiveUserId" th:field="*{receiveUserId}" class="form-control" type="text"
                       onblur="getNameDepartment()">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">领取人：</label>
            <div class="col-sm-8">
                <input name="receiveUser" th:field="*{receiveUser}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">领取部门：</label>
            <div class="col-sm-8">
                <input name="receiveDepartment" th:field="*{receiveDepartment}" class="form-control" type="text"
                       readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">领取数量：</label>
            <div class="col-sm-8">
                <input name="receiveCount" th:field="*{receiveCount}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">领取时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="receiveTime" th:value="${#dates.format(receiveRecord.receiveTime, 'yyyy-MM-dd')}"
                           class="form-control" placeholder="yyyy-MM-dd" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "consumables/receiveRecord";
    $("#form-receiveRecord-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-receiveRecord-edit').serialize());
        }
    };

    function getNameDepartment() {
        var userId = $("input[name='receiveUserId']").val();
        $.get("http://172.20.203.11/getoanamedept", {nameid: userId}, function (response) {
            var parse = JSON.parse(response);
            if (parse.code == "1") {
                $("input[name='receiveUser']").val(parse.name)
                $("input[name='receiveDepartment']").val(parse.parent)
            }
            if (parse.code != "1") {
                $("input[name='receiveUser']").val("")
                $("input[name='receiveDepartment']").val("")
            }
        });
    };


    $("input[name='receiveTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>